package com.example.demo.service;

import com.example.demo.dao.ProductRepository;
import com.example.demo.dao.StudentRepository;
import com.example.demo.dao.UserScoreRepository;
import com.example.demo.db.TargetDataSource;
import com.example.demo.po.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created With IntelliJ IDEA
 * User: Luweiwei
 * Date: 2017/12/19 6452
 * Time: 11:11
 * ProjectName: postgresqldemo
 * 实现
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private UserScoreRepository userScoreRepository;
    @Autowired
    private ProductRepository productRepository;
    @Autowired
    private StudentRepository studentRepository;

    @Override
    public List<Student> list() {
        return studentRepository.findAll();
    }

    @TargetDataSource(name = "ds1")
    @Override
    public String listDb1() {
        return userScoreRepository.findAll().toString();
    }

    @TargetDataSource(name = "ds2")
    @Override
    public String listDb2() {
        return productRepository.findAll().toString();
    }
}
